<?php  
/*error_reporting(E_ALL);
ini_set("display_errors", 1);*/
## include required files
/*******************************/
require_once '../model/testimonials.php';
require_once '../model/users.php';
/*******************************/
## Create Objects
/*******************************/
$testimonialObj = new Model_Testimonials();
$userObj	=	new Model_Users();
/*******************************/

$users	=$userObj->getAllActiveUsers();
$smarty->assign('users',$users);
echo '<pre>';print_r($users);echo '</pre>';die();
if(isset($_POST['addtestimonial_btn'])) {
	## apply PHP validation for required filed
	if(trim($_POST['testimonial_content']) != '') {
		$testimonialArray = array();
		extract($_POST);
		$testimonialArray['user'] 		= return_post_value($user);//$_SESSION["admin_firstname"].' '.$_SESSION["admin_lastname"];
		$testimonialArray['testimonial_content']        = strip_tags(return_post_value($testimonial_content));
		$testimonialArray['status']        = 0;
		$testimonialObj->addTestimonials($testimonialArray);
		$_SESSION['msg'] = "<div class='success_msg'><span>Testimonials added successfully</span></div>";
		header('location:'.SITE_URL.'/admin/home.php?q=testimonials');
		exit;
	} else {// php validation else
		$_SESSION['msg'] = 'Please enter testimonial Content';
	}
	// main if closed
}

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Set active class variable for left menu
$smarty->assign('activeclass', 'testimonials');
$smarty->assign('mainmenu', '2');
## Unset all the objects created which are on this page
unset($testimonialObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'testimonials/addtestimonial.tpl');
unset($smarty);
?>